home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / CachedViewEditor.cpp < prev    next >
Text File  |  1997-08-08  |  4KB  |  157 lines

  1. /*
  2.  *  File:       CachedViewEditor.cpp
  3.  *  Summary:       A view that knows how to edit a TCachedView.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    12/01/96    JDJ        Created
  12.  */
  13.  
  14. #include "CachedViewEditor.h"
  15.  
  16. #include <ZDialogUtils.h>
  17. #include <ZTextBox.h>
  18.  
  19.  
  20. // ===================================================================================
  21. //    class CEditCachedViewCommand
  22. // ===================================================================================
  23.  
  24. //---------------------------------------------------------------
  25. //
  26. // CEditCachedViewCommand::~CEditCachedViewCommand
  27. //
  28. //---------------------------------------------------------------
  29. CEditCachedViewCommand::~CEditCachedViewCommand()
  30. {
  31. }
  32.  
  33.  
  34. //---------------------------------------------------------------
  35. //
  36. // CEditCachedViewCommand::CEditCachedViewCommand
  37. //
  38. //---------------------------------------------------------------
  39. CEditCachedViewCommand::CEditCachedViewCommand(TCachedView* pane, const SCachedViewInfo& oldInfo, const SCachedViewInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  40. {
  41. }
  42.  
  43.  
  44. //---------------------------------------------------------------
  45. //
  46. // CEditCachedViewCommand::UpdatePane
  47. //
  48. //---------------------------------------------------------------
  49. void CEditCachedViewCommand::UpdatePane(const SCachedViewInfo& info)
  50. {
  51.     mPane->SetColorTable(info.colorTableID);
  52.     mPane->SetDepth(info.depth);
  53. }
  54.  
  55. #pragma mark -
  56.  
  57. // ===================================================================================
  58. //    CCachedViewEditor
  59. // ===================================================================================
  60.  
  61. static TReanimatorRegister<CCachedViewEditor> sCachedViewEditorRegistrar;
  62.  
  63. //---------------------------------------------------------------
  64. //
  65. // CCachedViewEditor::~CCachedViewEditor
  66. //
  67. //---------------------------------------------------------------
  68. CCachedViewEditor::~CCachedViewEditor()
  69. {
  70. }
  71.  
  72.  
  73. //---------------------------------------------------------------
  74. //
  75. // CCachedViewEditor::CCachedViewEditor
  76. //
  77. //---------------------------------------------------------------
  78. CCachedViewEditor::CCachedViewEditor(TView* superView) : Inherited(superView)
  79. {
  80. }
  81.  
  82.  
  83. //---------------------------------------------------------------
  84. //
  85. // CCachedViewEditor::Create                                [static]
  86. //
  87. //---------------------------------------------------------------
  88. MReanimatable* CCachedViewEditor::Create(MReanimatable* parent)
  89. {
  90.     return new CCachedViewEditor(dynamic_cast<TView*>(parent));
  91. }
  92.  
  93.  
  94. //---------------------------------------------------------------
  95. //
  96. // CCachedViewEditor::Validate
  97. //
  98. //---------------------------------------------------------------
  99. bool CCachedViewEditor::Validate()
  100. {
  101.     bool valid = Inherited::Validate();
  102.     
  103.     if (valid) {
  104.         TTextBox* textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Depth"));
  105.         short depth = textBox->GetValue();
  106.         if (depth != 1 && depth != 4 && depth != 8 && depth != 16 && depth != 32) {
  107.             DoStop(LoadAppString("That's not a valid bit depth!"), "");
  108.             textBox->SelectAll();
  109.             
  110.             valid = false;
  111.         }
  112.     }
  113.     
  114.     return valid;
  115. }
  116.  
  117.  
  118. //---------------------------------------------------------------
  119. //
  120. // CCachedViewEditor::GetEditorInfo        
  121. //
  122. //---------------------------------------------------------------
  123. SCachedViewInfo CCachedViewEditor::GetEditorInfo() const
  124. {
  125.     SCachedViewInfo info;
  126.     
  127.     TTextBox* textBox = nil;
  128.         
  129.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Clut"));
  130.     info.colorTableID = textBox->GetValue();
  131.     
  132.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Depth"));
  133.     info.depth = textBox->GetValue();
  134.     
  135.     return info;
  136. }
  137.  
  138.  
  139. //---------------------------------------------------------------
  140. //
  141. // CCachedViewEditor::SetEditorInfo
  142. //
  143. //---------------------------------------------------------------
  144. void CCachedViewEditor::SetEditorInfo(const SCachedViewInfo& info)
  145. {
  146.     TTextBox* textBox = nil;
  147.     
  148.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Clut"));
  149.     textBox->SetValue(info.colorTableID);
  150.     
  151.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Depth"));
  152.     textBox->SetValue(info.depth);
  153. }
  154.  
  155.  
  156.  
  157.